import { contextBridge, ipcRenderer } from 'electron';
// ai向main主进程通讯
contextBridge.exposeInMainWorld('electronAPI', {
  // 收起
  aiMinimization: () => ipcRenderer.send('open-ai-minimization'),
  // 展开
  aiMaximize: () => ipcRenderer.send('open-ai-maximize'),
  // 关闭
  aiClosePanel: () => ipcRenderer.send('open-ai-close'),
  // 注册监听
  receiveMessage: (channel, callback) => {
    const cbs = (event, ...args) => callback(...args);
    ipcRenderer.on(channel, cbs);
    return () => {
      ipcRenderer.off(channel, cbs);
    };
  },
});
